new Vue({
   el:"#app",
    data:{
       pageInfo:{},
       accountInfo:{}
    },
    methods:{

        updateAccount:function(){
            axios.post("/account/updateAccount.do",this.accountInfo).
            then(resp=>{
                this.accountInfo={};
                this.queryAccountByPage(1);
            });
        },

        openUpdateWindow:function(id){
            $("#update_modal").modal(true);//开启对话框
            axios.get("/account/queryAccountById.do?id="+id).
            then(resp=>{
                this.accountInfo = resp.data;
            });
        },

        saveAccount:function(){
          axios.post("/account/saveAccount.do?",this.accountInfo).
          then(resp=>{
              this.accountInfo={};
              this.queryAccountByPage(1);
          }).
          catch();
        },

       openAddWindow:function(){
           $("#add_modal").modal(true);//开启对话框
       },


        deleteAccountById:function(id){
            if(confirm("确定要删除吗")){
                axios.get("/account/deleteAccountById.do?id="+id).
                then(resp=>{
                    this.queryAccountByPage(1);
                }).
                catch()
            }
        },

        queryAccountByPage:function (currentPage) {
            axios.get("/account/queryAccountByPage.do?currentPage=" + currentPage).
            then(resp=>{
                this.pageInfo = resp.data;
                //console.log(resp.data);
            }).
            catch();
        }
    },

    //Vue对象的生命周期钩子函数
    //Vue对象挂载完div id=app标签后，调用此函数
    mounted:function () {
       this.queryAccountByPage(1);
    }
});